#include<bits/stdc++.h>
using namespace std;

long long a[200010];

int main()
{
	int n, k;
	cin>>n>>k;
	for(int i = 1;i <= n;i++)
	{
		cin>>a[i];
		a[i] += a[i-1];
	}
	unordered_map<int, int> mp;
	mp[0] = 1;
	long long ans = 0;
	for(int i = 1;i <= n;i++)
	{
		ans += mp[a[i]%k];
		mp[a[i]%k]++;
	}
	cout<<ans;
	return 0;
}
